﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;

namespace PM.Web
{
    public partial class ServicesInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Common.CheckUserOnline();
                bindData();
            }
        }

        private void bindData()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["type"]) && !string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                string sType = Request.QueryString["type"];
                if (sType == "1") { this.litTitle.Text = "请修单详情"; }
                else if (sType == "2") { this.litTitle.Text = "投诉单详情"; }
                else { this.litTitle.Text = "参数错误！"; Response.End(); }
                int id;
                if (!int.TryParse(Request.QueryString["id"], out id))
                {
                    this.litTitle.Text = "参数错误！";
                    Response.End();
                }
                else
                {
                    DataAccess.PmData dal = new DataAccess.PmData();
                    DataTable dt;
                    if (sType == "1")
                    {
                        dt = dal.GetRepair(id);
                        this.lblNo.Text = dt.Rows[0]["clts_no"].ToString();
                        this.txtUnitName.Text = dt.Rows[0]["self_unit_code"].ToString();
                        this.txtRepName.Text = dt.Rows[0]["u_repname"].ToString();
                        this.txtRepDate.Text = dt.Rows[0]["u_rep_date"].ToString();
                        this.txtHomeTel.Text = dt.Rows[0]["u_rep_hometel"].ToString();
                        this.txtRepWay.Text = dt.Rows[0]["u_rep_way"].ToString();
                        this.txtRepType.Text = dt.Rows[0]["u_rep_type"].ToString();
                        this.txtRepLevel.Text = dt.Rows[0]["u_rep_level"].ToString();
                        this.txtRepProjects.Text = dt.Rows[0]["u_rep_projects"].ToString();
                        this.txtRepKeyWord.Text = dt.Rows[0]["u_rep_key_word"].ToString();
                        this.txtRepRmk1.Text = dt.Rows[0]["u_rep_rmk1"].ToString();
                        this.radSmsY.Checked = Convert.ToBoolean(dt.Rows[0]["u_rep_sms_falg"]);
                        this.radSmsN.Checked = !Convert.ToBoolean(dt.Rows[0]["u_rep_sms_falg"]);
                        this.txtRepSomething.Text = dt.Rows[0]["u_rep_something"].ToString();
                        this.txtRepRcdName.Text = dt.Rows[0]["u_rep_rcdname"].ToString();
                        this.txtRepRcdDate.Text = dt.Rows[0]["u_rep_rcddate"].ToString();


                        this.txtSolveDept.Text = dt.Rows[0]["v_solve_dept"].ToString();
                        this.txtSolveName.Text = dt.Rows[0]["v_solve_name"].ToString();
                        this.txtSolveRmk2.Text = dt.Rows[0]["v_solve_rmk2"].ToString();
                        this.txtStatus.Text = dt.Rows[0]["v_solve_state"].ToString();
                        this.txtSolveDate1.Text = dt.Rows[0]["v_solve_date1"].ToString();
                        this.txtSolveDate2.Text = dt.Rows[0]["v_solve_date2"].ToString();
                        this.txtSolveLabor.Text = dt.Rows[0]["v_solve_c_labor"].ToString();
                        this.radLaborY.Checked = Convert.ToBoolean(dt.Rows[0]["v_solve_c_labor_flag"]);
                        this.radLaborN.Checked = !Convert.ToBoolean(dt.Rows[0]["v_solve_c_labor_flag"]);
                        this.txtSloveMaterials.Text = dt.Rows[0]["v_solve_c_materials"].ToString();
                        this.radMaterialsY.Checked = Convert.ToBoolean(dt.Rows[0]["v_solve_c_materials_flag"]);
                        this.radMaterialsN.Checked = !Convert.ToBoolean(dt.Rows[0]["v_solve_c_materials_flag"]);
                        this.txtSolveCostPay.Text = dt.Rows[0]["v_solve_costpay"].ToString();
                        this.txtSolvePayType.Text = dt.Rows[0]["v_solve_c_paytype"].ToString();
                        this.txtSolveReultMan.Text = dt.Rows[0]["v_solve_reult_man"].ToString();
                        this.txtSolveRcdName.Text = dt.Rows[0]["v_solve_rcdname"].ToString();
                        this.txtSolveRcdDate.Text = dt.Rows[0]["v_solve_rcddate"].ToString();
                    }
                    if (sType == "2")
                    {
                        dt = dal.GetComplaints(id);
                        this.lblComNo.Text = dt.Rows[0]["clts_no"].ToString();
                        this.txtComUnitName.Text = dt.Rows[0]["self_unit_code"].ToString();
                        this.txtComRepName.Text = dt.Rows[0]["u_repname"].ToString();
                        this.txtComRepDate.Text = dt.Rows[0]["u_rep_date"].ToString();
                        this.txtComHomeTel.Text = dt.Rows[0]["u_rep_hometel"].ToString();
                        this.txtComRepWay.Text = dt.Rows[0]["u_rep_way"].ToString();
                        this.txtComRepType.Text = dt.Rows[0]["u_rep_type"].ToString();
                        this.txtComRepLevel.Text = dt.Rows[0]["u_rep_level"].ToString();
                        this.txtComRepProjects.Text = dt.Rows[0]["u_rep_projects"].ToString();
                        this.txtComRepKeyWord.Text = dt.Rows[0]["u_rep_key_word"].ToString();
                        this.txtComRepRmk1.Text = dt.Rows[0]["u_rep_rmk1"].ToString();
                        this.radComSmsY.Checked = Convert.ToBoolean(dt.Rows[0]["u_rep_sms_falg"]);
                        this.radComSmsN.Checked = !Convert.ToBoolean(dt.Rows[0]["u_rep_sms_falg"]);
                        this.txtComRepSomething.Text = dt.Rows[0]["u_rep_something"].ToString();
                        this.txtComRepRcdName.Text = dt.Rows[0]["u_rep_rcdname"].ToString();
                        this.txtComRepRcdDate.Text = dt.Rows[0]["u_rep_rcddate"].ToString();


                        this.txtComSolveDept.Text = dt.Rows[0]["v_solve_dept"].ToString();
                        this.txtComSolveName.Text = dt.Rows[0]["v_solve_name"].ToString();
                        this.txtComSolveRmk2.Text = dt.Rows[0]["v_solve_rmk2"].ToString();
                        this.txtComStatus.Text = dt.Rows[0]["v_solve_state"].ToString();
                        this.txtComSolveDate1.Text = dt.Rows[0]["v_solve_date1"].ToString();
                        this.txtComSolveDate2.Text = dt.Rows[0]["v_solve_date2"].ToString();
                        //this.txtComSolveLabor.Text = dt.Rows[0]["v_solve_c_labor"].ToString();
                        //this.radComLaborY.Checked = Convert.ToBoolean(dt.Rows[0]["v_solve_c_labor_flag"]);
                        //this.radComLaborN.Checked = !Convert.ToBoolean(dt.Rows[0]["v_solve_c_labor_flag"]);
                        //this.txtComSloveMaterials.Text = dt.Rows[0]["v_solve_c_materials"].ToString();
                        //this.radComMaterialsY.Checked = Convert.ToBoolean(dt.Rows[0]["v_solve_c_materials_flag"]);
                        //this.radComMaterialsN.Checked = !Convert.ToBoolean(dt.Rows[0]["v_solve_c_materials_flag"]);
                        //this.txtComSolveCostPay.Text = dt.Rows[0]["v_solve_costpay"].ToString();
                        //this.txtComSolvePayType.Text = dt.Rows[0]["v_solve_c_paytype"].ToString();
                        //this.txtComSolveReultMan.Text = dt.Rows[0]["v_solve_reult_man"].ToString();
                        this.txtComSolveRcdName.Text = dt.Rows[0]["v_solve_rcdname"].ToString();
                        this.txtComSolveRcdDate.Text = dt.Rows[0]["v_solve_rcddate"].ToString();
                    }
                    

                }
            }
            else
            {
                this.litTitle.Text = "参数错误！";
                Response.End();
            }
        }
    }
}